/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kungkhies.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author clayton
 */
@Entity 
@Table(name = "kungkher")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Kungkher.findAll", query = "SELECT k FROM Kungkher k"),
    @NamedQuery(name = "Kungkher.findByKungkherId", query = "SELECT k FROM Kungkher k WHERE k.kungkherId = :kungkherId"),
    @NamedQuery(name = "Kungkher.findByFullname", query = "SELECT k FROM Kungkher k WHERE k.fullname = :fullname"),
    @NamedQuery(name = "Kungkher.findByUsername", query = "SELECT k FROM Kungkher k WHERE k.username = :username"),
    @NamedQuery(name = "Kungkher.findByPassword", query = "SELECT k FROM Kungkher k WHERE k.password = :password"),
    @NamedQuery(name = "Kungkher.findByEmail", query = "SELECT k FROM Kungkher k WHERE k.email = :email"),
    @NamedQuery(name = "Kungkher.findByDateRegistered", query = "SELECT k FROM Kungkher k WHERE k.dateRegistered = :dateRegistered")
})
public class Kungkher implements Serializable 
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "kungkher_id")
    private Long kungkherId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 256)
    @Column(name = "fullname")
    private String fullname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "username")
    private String username;
    @Size(max = 15)
    @Column(name = "password")
    private String password;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 256)
    @Column(name = "email")
    private String email;
    @Lob
    @Size(max = 65535)
    @Column(name = "interests")
    private String interests;
    @Basic(optional = false)
    @NotNull
    @Column(name = "date_registered")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateRegistered;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kungkherId")
    private Collection<Kspace> kspaceCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "publisherId")
    private Collection<KungkhieImpl> kungkhieImplCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "publisherId")
    private Collection<Kungkhie> kungkhieCollection;

    public Kungkher()
    {
    }

    public Kungkher(Long kungkherId)
    {
        this.kungkherId = kungkherId;
    }

    public Kungkher(Long kungkherId, String fullname, String username, Date dateRegistered)
    {
        this.kungkherId = kungkherId;
        this.fullname = fullname;
        this.username = username;
        this.dateRegistered = dateRegistered;
    }

    public Long getKungkherId()
    {
        return kungkherId;
    }

    public void setKungkherId(Long kungkherId)
    {
        this.kungkherId = kungkherId;
    }

    public String getFullname()
    {
        return fullname;
    }

    public void setFullname(String fullname)
    {
        this.fullname = fullname;
    }

    public String getUsername()
    {
        return username;
    }

    public void setUsername(String username)
    {
        this.username = username;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }

    public String getInterests()
    {
        return interests;
    }

    public void setInterests(String interests)
    {
        this.interests = interests;
    }

    public Date getDateRegistered()
    {
        return dateRegistered;
    }

    public void setDateRegistered(Date dateRegistered)
    {
        this.dateRegistered = dateRegistered;
    }

    @XmlTransient
    public Collection<Kspace> getKspaceCollection()
    {
        return kspaceCollection;
    }

    public void setKspaceCollection(Collection<Kspace> kspaceCollection)
    {
        this.kspaceCollection = kspaceCollection;
    }

    @XmlTransient
    public Collection<KungkhieImpl> getKungkhieImplCollection()
    {
        return kungkhieImplCollection;
    }

    public void setKungkhieImplCollection(Collection<KungkhieImpl> kungkhieImplCollection)
    {
        this.kungkhieImplCollection = kungkhieImplCollection;
    }

    @XmlTransient
    public Collection<Kungkhie> getKungkhieCollection()
    {
        return kungkhieCollection;
    }

    public void setKungkhieCollection(Collection<Kungkhie> kungkhieCollection)
    {
        this.kungkhieCollection = kungkhieCollection;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (kungkherId != null ? kungkherId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Kungkher))
        {
            return false;
        }
        Kungkher other = (Kungkher) object;
        if ((this.kungkherId == null && other.kungkherId != null) || (this.kungkherId != null && !this.kungkherId.equals(other.kungkherId)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.kungkhies.persistence.entities.Kungkher[ kungkherId=" + kungkherId + " ]";
    }

}
